var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/cmd/commit-lint.ts
var commit_lint_exports = {};
__export(commit_lint_exports, {
  commitlint: () => commitlint,
  default: () => commit_lint_default
});
module.exports = __toCommonJS(commit_lint_exports);
var import_path = require("path");
var import_load = __toESM(require("@commitlint/load"));
var import_read = __toESM(require("@commitlint/read"));
var import_lint = __toESM(require("@commitlint/lint"));
var import_format = __toESM(require("@commitlint/format"));
var commitlint = async ({ cwd }) => {
  try {
    const [message] = await (0, import_read.default)({
      edit: (0, import_path.join)(cwd, ".git/COMMIT_EDITMSG")
    });
    const opts = await (0, import_load.default)(require("../../config/.commitlintrc.js"));
    const report = await (0, import_lint.default)(message, opts.rules, opts.parserPreset ? { parserOpts: opts.parserPreset.parserOpts } : {});
    if (report.errors && report.errors.length) {
      console.error((0, import_format.default)({ results: [report] }));
      process.exitCode = 1;
    }
  } catch (err) {
    process.exitCode = 1;
  }
};
var commit_lint_default = (api) => {
  api.registerCommand({
    name: "commitlint",
    description: "lint commit messages by commitlint",
    details: `
  $ umi commitlint
    `,
    async fn() {
      const { cwd } = api.paths;
      commitlint({ cwd });
    }
  });
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  commitlint
});
